<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<!DOCTYPE html>
<html lang="en">
<head>
<jsp:include page="../../header.jsp" />
</head>
<body>
<div class="container-fluid">
	<div class="page-header clearfix">
 		<div class="pull-left">
 			<a href="javascript:history.go(-1);" class="btn btn-link btn-xs"><i class="icon-reply"></i> 返回</a>
       		<a href="javascript:window.location.reload();" class="btn btn-link btn-xs"><i class="icon-refresh"></i> 刷新页面</a>
      	</div>
     	<div class="pull-right crumbs">
     		<i class=" icon-map-marker"></i> <span>当前位置：菜单管理(${pname})</span>
      	</div>
    </div>
	<div class="container-panel">
	   <div class="content">
	   		 <form class="form-horizontal" action="${action}" id="form">
	   		 <table class="table form-table table-condensed">
	   		 	<tr>
	   		 		<td class="tdleft" width="6%">*员工姓名:</td>
	   		 		<td class="tdright" width="19%"><input type="text" name="name" value="${user.name}" placeholder="员工名称" class="form-control input-sm"></td>
	   		 		<td class="tdleft" width="6%">*姓名拼音:</td>
	   		 		<td class="tdright" width="19%"><input type="text" name="pinyin" value="${user.pinyin}" placeholder="姓名拼音" class="form-control input-sm"></td>
	   		 		<td class="tdleft" width="6%">*登录名:</td>
	   		 		<td class="tdright" width="19%"><input type="text" name="loginName" value="${user.loginName}" placeholder="登录名" class="form-control input-sm"></td>
	   		 		<td class="tdleft" width="6%">*密码:</td>
	   		 		<td class="tdright" width="19%"><input type="text" name="loginPwd" value="" placeholder="密码" class="form-control input-sm"></td>
	   		 	</tr>
	   		 	<tr>
	   		 		<td class="tdleft">*性别:</td>
	   		 		<td class="tdright">
	   		 			<select class="form-control input-sm" name="sex">
	   		 					<option value="" <c:if test="${user.sex==null}">selected</c:if> >请选择</option>
				            	<option value="男" <c:if test="${user.sex=='男'}">selected</c:if> >男</option>
				            	<option value="女" <c:if test="${user.sex=='女'}">selected</c:if> >女</option>
			              </select>
	   		 		</td>
	   		 		<td class="tdleft">*选择部门:</td>
	   		 		<td class="tdright">
	   		 			<select class="form-control input-sm" name="organization.id">
				            <c:forEach var="r" items="${organizations}" varStatus="s">
				            	<option value="${r.id}" <c:if test="${user.organization.id==r.id}">selected</c:if> >${r.name}</option>
				            </c:forEach>
			              </select>
	   		 		</td>
	   		 		<td class="tdleft">*选择角色:</td>
	   		 		<td class="tdright" colspan="3">
						<c:forEach var="r" items="${roles}" varStatus="s">
				            	<input type="checkbox" name="roleId" value="${r.id}" >${r.name}
				            </c:forEach>
					</td>
	   		 	</tr>
	   		 </table>
	            <input type="hidden" name="id" value="${user.id}" />
          </form>
			<div class="form-btns">
			   <button type="button" class="btn btn-primary btn-sm" onclick="sub();">提交</button>
			</div>
	</div>
</div>
</div>
	<script type="text/javascript">
	$(function() {
		<c:forEach items="${user.roles}" var="k">
		$("input[name='roleId']:checkbox[value='${k.id}']").prop('checked',
				'true');
		</c:forEach>
	});
	function sub(){
		$.ajax({
			type : "POST",
			data : $("#form").serialize(),
			url : $("#form").attr("action"),
			dataType : 'json',
			success:function(data) {
				if(data.status==1){
					msg.confirm(data.info,function(){
						window.location.reload();
			    	},"操作提示");
				}else{
					msg.info(data.info);
				}
			}
		});
	}
	</script>
</body>
</html>
